<template>
  <el-dialog v-model="dialogFormVisible" title="角色操作" width="500">
    <el-form :model="role">
      <el-form-item label="角色ID" label-width="110px">
        <el-input v-model="role.roleId" autocomplete="off" style="width: 300px" readonly />
      </el-form-item>
      <el-form-item label="角色名称" label-width="110px">
        <el-input v-model="role.roleName" autocomplete="on" style="width: 300px" clearable />
      </el-form-item>
      <el-form-item label="角色备注" label-width="110px">
        <el-input
          v-model="role.remarks"
          autocomplete="off"
          clearable
          style="width: 300px"
          :autosize="{ minRows: 2, maxRows: 8 }"
          rows="7"
          type="textarea"
          placeholder="请输入备注"
        />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleCancel">取消</el-button>
        <el-button type="primary" @click="handleSubmit(role)"> 提交 </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { useRoleStore } from '@/stores/role/role.js'
import { storeToRefs } from 'pinia'
const roleStore = useRoleStore()
const { role, dialogFormVisible } = storeToRefs(roleStore)

const handleSubmit = (role) => {
  roleStore.handleSubmit(role)
  // console.log(roles[role.roleId])
  dialogFormVisible.value = false
}
const handleCancel = () => {
  roleStore.setDialogFormVisible(false)
  roleStore.setRole({ roleId: -1 })
}
</script>

<style scoped lang="scss"></style>
